<template>
  <div class="index-container">
    <!-- 顶部标题 -->
    <div class="header">
      <h1>沈阳云医院</h1>
    </div>

    <!-- 健康生活横幅 -->
    <div class="banner">
      <img src="@/assets/logo.png" alt="健康生活" class="banner-img">
      <div class="banner-text">健康生活</div>
    </div>

    <!-- 功能卡片网格 -->
    <div class="function-grid">
      <div 
        v-for="(item, index) in functionItems" 
        :key="index" 
        class="function-card"
        @click="handleFunctionClick(item.path)"
      >
        <img 
          :src="getIconPath(index)" 
          :alt="item.title"
          class="function-icon"
        >
        <div class="function-title">{{ item.title }}</div>
        <div class="function-desc">{{ item.desc }}</div>
      </div>
    </div>

   
    <!-- 健康报告区域 -->
    <div class="health-report">
      <div class="report-content">
        <div class="report-title">我的健康报告</div>
        <div class="report-desc">随时随地查看体检报告</div>
        <button class="view-btn" @click="goToReport">立即查看</button>
      </div>
    </div>

    <!-- 底部导航 -->
    <div class="bottom-nav">
      <div class="nav-item" :class="{ active: currentNav === 'hospital' }">
        <span class="nav-icon">🏥</span>
        <span class="nav-text">云医院</span>
      </div>
      <div class="nav-item" :class="{ active: currentNav === 'mall' }">
        <span class="nav-icon">🛒</span>
        <span class="nav-text">商城</span>
      </div>
      <div class="nav-item" :class="{ active: currentNav === 'discover' }">
        <span class="nav-icon">🔍</span>
        <span class="nav-text">发现</span>
      </div>
      <div class="nav-item" :class="{ active: currentNav === 'personal' }" @click="goToPersonal">
        <span class="nav-icon">👤</span>
        <span class="nav-text">我</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const currentNav = ref('hospital')

// 功能项数据
const functionItems = [
  { title: '免费咨询', desc: '新型冠状病毒肺炎', path: '/exam-custom' },
  { title: '网络问诊', desc: '图文视频网络咨询', path: '/free-consult' },
  { title: 'e心门诊', desc: '复旦医科大学专家', path: '/online-consult' },
  { title: '慢病管理', desc: '血压血糖健康管理', path: '/e-clinic' },
  { title: '上门护理', desc: '网上购买上门服务', path: '/chronic-management' },
  { title: '团检预约', desc: '团体体检套餐定制', path: '/appointment' }
]

// 获取图标路径
const getIconPath = (index) => {
  return new URL(`../assets/menu0${index + 1}.png`, import.meta.url).href
}

// 处理功能点击
const handleFunctionClick = (path) => {
  router.push(path)
}

// 跳转到预约页面
const goToAppointment = () => {
  router.push('/appointment')
}

// 跳转到健康档案页面
const goToReport = () => {
  router.push('/reportlist')
}

// 跳转到个人中心
const goToPersonal = () => {
  router.push('/personal')
}
</script>

<style scoped>
.index-container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 60px;
}

.header {
  background: white;
  padding: 15px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.banner {
  position: relative;
  margin: 15px;
  border-radius: 8px;
  overflow: hidden;
}

.banner-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.banner-text {
  position: absolute;
  bottom: 10px;
  left: 15px;
  color: white;
  font-size: 16px;
  font-weight: bold;
}

.function-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  padding: 15px;
  background: white;
  margin: 15px;
  border-radius: 8px;
}

.function-card {
  text-align: center;
  padding: 10px 5px;
  cursor: pointer;
}

.function-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 5px;
}

.function-title {
  font-size: 12px;
  color: #333;
  margin-bottom: 2px;
}

.function-desc {
  font-size: 10px;
  color: #666;
  line-height: 1.2;
}

.group-appointment,
.health-report {
  background: white;
  margin: 15px;
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
}

.appointment-title,
.report-title {
  font-size: 16px;
  color: #333;
  font-weight: bold;
  margin-bottom: 5px;
}

.appointment-desc,
.report-desc {
  font-size: 12px;
  color: #666;
}

.view-btn {
  background: #1890ff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  margin-top: 10px;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
  border-top: 1px solid #eee;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.nav-text {
  font-size: 10px;
  color: #666;
}

.nav-item.active .nav-text {
  color: #1890ff;
}
</style>